google.load("visualization", "1", {packages:["corechart"]});

var color_winner = '#FF2222';
var color_loser = '#FFAAAA';

function display_one_dim_result(dimension_name, left_value,right_value,middle_value) {
    var data = new google.visualization.DataTable();
	// var offset = Math.min(left_value,right_value) < 0 ? -2 * Math.min(left_value,right_value) : 0;
	data.addColumn('string', 'Color');
	data.addColumn('number', 'score left');
	data.addColumn('number','');
	data.addColumn('number', 'score right');
	data.addRows([
	  [dimension_name,left_value,middle_value- (left_value + right_value), right_value]
	]);

	var options = {
	  width: 600, left: 300, height: 40,
	  title: 'Flickr fight',
	  vAxis: {textPosition: 'in'},
	  hAxis: {viewWindowMode: 'maximized', maxValue: left_value+right_value+middle_value},
	  isStacked: true
	};
	
	if (left_value > right_value) {
		if(dark_colors[dimension_name] != null) {
			options.colors = [dark_colors[dimension_name],'white',light_colors[dimension_name]];
		}
		else {
			options.colors = [color_winner,'white',color_loser];
		}
	}
	else {
		if(dark_colors[dimension_name] != null) {
			options.colors = [light_colors[dimension_name],'white',dark_colors[dimension_name]];
		}
		else {
			options.colors = [color_loser,'white',color_winner];
		}
	}

	var chart = new google.visualization.BarChart(document.getElementById(dimension_name.concat('_chart')));
	chart.draw(data, options);
}
